<?php
namespace app\admin\model;
use think\Model;
use think\Db;
class Category extends Model{


    protected $tableName = 'category';
    public function createTree($data,$parent_id = 0, $level = 1)
    {
      static $new_arr = array();
        foreach ($data as $key => $value) {
            if ($value['parent_id'] == $parent_id) {
             $value['level'] = $level;
                $new_arr[] = $value;

                $this->createTree($data, $value['cat_id'], $level + 1);
            }
        }
        return $new_arr;
    }




    
}



?>